<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>编辑组织机构</title>
<link rel="stylesheet" type="text/css" href="$request.getContextPath()/resources/layui/css/layui.css">
</head>
<body>
<form class="layui-form" action="">
  <input type="hidden" name="orgId" value="$!organize.orgId">
  <div class="layui-form-item">
    <label class="layui-form-label">机构名称</label>
    <div class="layui-input-inline">
      <input type="text" name="orgName" value="$!organize.orgName" required  lay-verify="required" placeholder="请输入机构名称" autocomplete="off" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">机构名称不可重复</div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">父机构</label>
    <div class="layui-input-inline">
      <select name="parentOrgId" required lay-verify="required">
        <option value="0">顶级机构</option>
        #foreach($org in $organizes)
           #if($!organize.parentOrgId==$org.orgId)
        	<option value="$org.orgId" selected="selected">$org.orgName</option>
           #else
        	<option value="$org.orgId">$org.orgName</option>
           #end
        #end
      </select>
    </div>
    <div class="layui-form-mid layui-word-aux">指定父机构名称</div>
  </div>
  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">机构描述</label>
    <div class="layui-input-block">
      <textarea id="organizeDesc" name="remark" placeholder="请输入机构描述" class="layui-textarea">$!organize.remark</textarea>
    </div>
  </div>
  <div class="layui-form-item">
    <div class="layui-input-block submit-btn">
      <button class="layui-btn" lay-submit lay-filter="editOrganizeuForm">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>
</body>
<script type="text/javascript" src="$request.getContextPath()/resources/jquery/jquery-3.1.0.min.js"></script>
<script type="text/javascript" src="$request.getContextPath()/resources/layui/layui.js"></script>
<script type="text/javascript" src="$request.getContextPath()/resources/layui/lay/modules/element.js"></script>
<script type="text/javascript">
$(function(){
	layui.use(['form', 'layedit', 'laydate'], function(){
		var form = layui.form(),layer = layui.layer,layedit = layui.layedit,laydate = layui.laydate;
		var organizeDescIndex=layedit.build('organizeDesc',{
          tool: [
            'strong' //加粗
            ,'italic' //斜体
            ,'underline' //下划线
            ,'|' //分割线
            ,'left' //左对齐
            ,'center' //居中对齐
            ,'right' //右对齐
          ]
        }); //建立编辑器
		//监听提交
		form.on('submit(editOrganizeuForm)', function(data){
		    var remark=layedit.getContent(organizeDescIndex);
		    data.field.remark=remark;
		    data.field._method="put";
			$.post("$request.getContextPath()/system/organize/edit",data.field,function(data){
				//保存成功 关闭当前页
				top.layer.msg(data.msg,{
					icon: 1,
					skin: 'demo-class',
					title :'信息',
					time:2000,
				    area: ['300px', '160px'],
				    offset: 'rb',
				    end :function(){
				    	if(data.code==200){
				    		var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
							parent.layer.close(index); //再执行关闭   
						}
				    }
				});
			});		
		    return false;
		});
	});
});
</script>
</html>